﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Win32;

namespace MontagsmalerApp.Views
{
	/// <summary>
	/// Interaktionslogik für TeamsWindow.xaml
	/// </summary>
	public partial class TeamsWindow : Window
	{
		private MainWindow _mainWindow;

		public TeamsWindow(MainWindow sender, bool allowEdit)
		{
			InitializeComponent();
			_mainWindow = sender;
			spielerverwaltungPflege1.IsEnabled = allowEdit;
		}

		private void btnSpeichern_Click(object sender, RoutedEventArgs e)
		{
			SaveFileDialog dialog = new SaveFileDialog();
			dialog.Title = "Teams speichern ...";
			dialog.Filter = "Team Save File (*.tsv)|*.tsv|All files (*.*)|*.*";
			if (dialog.ShowDialog(this) == true)
			{
				_mainWindow.Spiel.SpeichereTeams(dialog.FileName);
			}
		}

		private void btnLaden_Click(object sender, RoutedEventArgs e)
		{
			OpenFileDialog dialog = new OpenFileDialog();
			dialog.Title = "Teams laden ...";
			dialog.Filter = "Team Save File (*.tsv)|*.tsv|All files (*.*)|*.*";
			if (dialog.ShowDialog(this) == true)
			{
				_mainWindow.Spiel.LadeTeams(dialog.FileName);
			}

			spielerverwaltungPflege1.Refresh();
		}

		private void btnZuruecksetzen_Click(object sender, RoutedEventArgs e)
		{
			spielerverwaltungPflege1.PunkteZuruecksetzen();
		}
	}
}
